package lib

import "algorithms/ds"

func init() {
	Probs = append(Probs, Problem{
		Num:         94,
		Discription: "二叉树中序遍历",
		Level:       1,
		Labels: map[string]int{
			"递归":  1,
			"二叉树": 1,
		},
	})
}

func InorderTraversal(root *ds.TreeNode) []int {
	res := make([]int, 0)
	var midOrder func(*ds.TreeNode)
	midOrder = func(node *ds.TreeNode) {
		if node == nil {
			return
		}

		midOrder(node.Left)
		res = append(res, node.Val)
		midOrder(node.Right)
	}

	midOrder(root)
	return res
}
